
package GUIs;
import javax.persistence.EntityManager;

// author dimi
 
public class PurchasesGUI extends javax.swing.JFrame {

    private EntityManager em;
    
    // Ορίζω ως γονέα τη φόρμα CustomerGUI
    private CustomerGUI parent;
    // Ορίζω τις φόρμες που θα ανοίγουν με τις επιλογές κουμπιών της CustomerGUI
    //private CustomerProfileGUI childForm;
    private Purchases_ProductsSelectionGUI childForm1;
        
    public PurchasesGUI(CustomerGUI parent, EntityManager em) {
        this.em = em;
        this.parent = parent;
        initComponents();
        setLocationRelativeTo(null); // Κεντράρει το παράθυρο στην οθόνη
    
    } // end of PurchasesGUI Constructor

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        Panel_PurchasesGUI_Welcome = new javax.swing.JPanel();
        Label_PurchasesGUI_Welcome = new javax.swing.JLabel();
        Button_PurchasesGUI_Exit = new javax.swing.JButton();
        Table_PurchasesGUI_StoresList = new javax.swing.JScrollPane();
        jTable2 = new javax.swing.JTable();
        jButton2 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        Panel_PurchasesGUI_Welcome.setBackground(new java.awt.Color(0, 153, 153));

        Label_PurchasesGUI_Welcome.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        Label_PurchasesGUI_Welcome.setForeground(new java.awt.Color(153, 255, 255));
        Label_PurchasesGUI_Welcome.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        Label_PurchasesGUI_Welcome.setText("ΑΓΟΡΕΣ ΠΡΟΪΟΝΤΩΝ - ΕΠΙΛΟΓΗ ΚΑΤΑΣΤΗΜΑΤΟΣ");

        javax.swing.GroupLayout Panel_PurchasesGUI_WelcomeLayout = new javax.swing.GroupLayout(Panel_PurchasesGUI_Welcome);
        Panel_PurchasesGUI_Welcome.setLayout(Panel_PurchasesGUI_WelcomeLayout);
        Panel_PurchasesGUI_WelcomeLayout.setHorizontalGroup(
            Panel_PurchasesGUI_WelcomeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(Panel_PurchasesGUI_WelcomeLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(Label_PurchasesGUI_Welcome, javax.swing.GroupLayout.DEFAULT_SIZE, 466, Short.MAX_VALUE)
                .addContainerGap())
        );
        Panel_PurchasesGUI_WelcomeLayout.setVerticalGroup(
            Panel_PurchasesGUI_WelcomeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(Label_PurchasesGUI_Welcome)
        );

        Button_PurchasesGUI_Exit.setText("ΕΞΟΔΟΣ");
        Button_PurchasesGUI_Exit.setBorder(new javax.swing.border.MatteBorder(null));
        Button_PurchasesGUI_Exit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Button_PurchasesGUI_ExitActionPerformed(evt);
            }
        });

        jTable2.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        Table_PurchasesGUI_StoresList.setViewportView(jTable2);

        jButton2.setText("Επιλογή καταστήματος");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(Panel_PurchasesGUI_Welcome, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addGap(0, 0, Short.MAX_VALUE)
                .addComponent(Button_PurchasesGUI_Exit))
            .addComponent(Table_PurchasesGUI_StoresList)
            .addGroup(layout.createSequentialGroup()
                .addGap(177, 177, 177)
                .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 149, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(Panel_PurchasesGUI_Welcome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 8, Short.MAX_VALUE)
                .addComponent(Table_PurchasesGUI_StoresList, javax.swing.GroupLayout.PREFERRED_SIZE, 198, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jButton2)
                .addGap(19, 19, 19)
                .addComponent(Button_PurchasesGUI_Exit))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        System.out.println("Επιλογή Εξόδου από τη φόρμα Αγορών");
        parent.setEnabled(true); // Ενεργοποιώ πάλι το παράθυρο της προηγούμενης φόρμας
        dispose();
    }//GEN-LAST:event_formWindowClosing

    private void Button_PurchasesGUI_ExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Button_PurchasesGUI_ExitActionPerformed
        System.out.println("Επιλογή Εξόδου από τη φόρμα Αγορών");
        parent.setEnabled(true); // Ενεργοποιώ πάλι το παράθυρο της προηγούμενης φόρμας
        dispose();
        
    }//GEN-LAST:event_Button_PurchasesGUI_ExitActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        System.out.println("Σύνδεση με Γραφικό Περιβάλλον ΕΠιλογής Προϊόντων");
        
        // Όταν επιλέξει ο χρήστης αυτό το κουμπί, εισερχόμαστε στη φόρμα Επιλογής
        // Προϊόντων, που θέτουμε ως childForm1
        childForm1 = new Purchases_ProductsSelectionGUI(this, em);
        
        // Ενεργοποιούμε το νέο παράθυρο Επιλογής Προϊόντων
        childForm1.setVisible(true);
        
        // Απενεργοποιούμε το τρέχον παράθυρο CustomerGUI
        setEnabled(false);
    }//GEN-LAST:event_jButton2ActionPerformed

    

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton Button_PurchasesGUI_Exit;
    private javax.swing.JLabel Label_PurchasesGUI_Welcome;
    private javax.swing.JPanel Panel_PurchasesGUI_Welcome;
    private javax.swing.JScrollPane Table_PurchasesGUI_StoresList;
    private javax.swing.JButton jButton2;
    private javax.swing.JTable jTable2;
    // End of variables declaration//GEN-END:variables
}
